package cn.kgc.controller;

import cn.kgc.service.DevUserSercive;
import cn.kgc.service.impl.DevUserSerciveImpl;
import cn.kgc.service.impl.DevUserSerciveImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;

import javax.servlet.http.HttpSession;

/**
 * Created by Administrator on 2018/9/13/013.
 */
@Controller
@RequestMapping("/dev")
public class DevController {
    @Autowired
    private DevUserSercive devUserService;
    @RequestMapping("/jump")
    public String jump(){
        return "devlogin";
    }
    @RequestMapping(value = "/devLogin",method = RequestMethod.POST)
    public String selectLogin(@RequestParam("devCode") String devCode,
                              @RequestParam("devPassword") String devPassword,
                              HttpSession session){
        String devName = devUserService.selectLogin(devCode,devPassword);
        if(devName!=null){
            session.setAttribute("devName",devName);
            return "developer/main";
        }else{
            return "devlogin";
        }
    }
    @RequestMapping("/loginOut")
    public String loginOut(HttpSession session){
        session.removeAttribute("devName");
        session.invalidate();
        return "devlogin";
    }
}
